package com.hooker.listener;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

public class LaunchListener {

    private static final String ACTION = "ACTION_GUUMOB_LAUNCH";
    private static final String VOLUME_CHANGE_ACTION = "android.media.VOLUME_CHANGED_ACTION";

    private static onReceiveListener listener;

    public static void send(Context context) {
        context.sendBroadcast(new Intent(ACTION));
    }

    public static void register(Context context, onReceiveListener l) {
        IntentFilter filter = new IntentFilter(ACTION);
        filter.addAction(VOLUME_CHANGE_ACTION);
        context.registerReceiver(new LaunchReceiver(), filter);
        listener = l;
    }

    public static class LaunchReceiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (listener != null) {
                listener.onReceive();
            }
        }
    }

    public interface onReceiveListener {
        void onReceive();
    }
}
